import { defineStore } from "pinia";
import { ref } from "vue";

export const useUserStore = defineStore("user", ()=>{
        const token = ref('')
        function setToken(value){
                token.value = value
        }
        const userInfo = ref({})
        const setUserInfo = (user) => {
                userInfo.value = user
        }
     function  removeToken(){
                token.value = ''
        }
        function removeUserInfo(){
                userInfo.value = {}
        }

        return {
                token,setToken,setUserInfo,userInfo,removeToken,removeUserInfo
        }
},
        {
                persist:{
                   storage: sessionStorage,
                }
        }
)